<template>
	<view class="mainpadding" v-if="pageShow">
		<image class="fpbjt" :src="dataAll.image_text" @click="lbtpriview(0,[dataAll.image_text])" mode=""></image>
		<view class="bigbtn margin_top" @click="saveimg(dataAll.image_text)">保存发票</view>
		<!-- 酒店订单 -->
		<view class="ffffff mainpadding radius" v-if="data_type==1">
			<view class="ershiba zhonghei fonweight">订单编号：{{dataAll.order.order_no}}</view>
			<view class="flexbetween margin_top ">
				<image class="sptp" :src="dataAll.order.hoteltype.image_text" mode=""></image>
				<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
					<view class="ershiba xiaohei yhxk">{{dataAll.order.hoteltype.name}}</view>
					<view class="flexbetween margin_top1" style="width: 100%;">
						<view class="titletext xiaohong fonweight">¥{{dataAll.order.pay_price}}</view>
						<view class="ershil xiaocheng">x{{dataAll.order.people_num}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 商品订单 -->
		<view class="ffffff mainpadding radius" v-if="data_type==2">
			<view class="ershiba zhonghei fonweight">订单编号：{{dataAll.order.order_no}}</view>
			<view class="flexbetween margin_top " v-for="item in dataAll.order.goods" :key="item.id">
				<image class="sptp" :src="item.image_text" mode=""></image>
				<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
					<view class="ershiba xiaohei yhxk">{{item.title}}</view>
					<view class="flexbetween margin_top1" style="width: 100%;">
						<view class="titletext xiaohong fonweight">¥{{item.actual_payment}}</view>
						<view class="ershil xiaocheng">x{{item.number}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="ffffff mainpadding radius margin_top">
			<view class="ershiba zhonghei fonweight">发票类型</view>
			<view class="ershiba xiaohui  margin_top4">发票类型：{{dataAll.fp_type==1?"电子发票":"增值税专用发票"}}</view>
			<view class="ershiba xiaohui  margin_top">抬头类型：{{dataAll.tt_type==1?"个人":"单位"}}</view>
			<view class="ershiba xiaohui  margin_top">抬头名称：{{dataAll.name}}</view>
			<view class="ershiba xiaohui  margin_top">申请时间：{{dataAll.createtime_text}}</view>
			<view class="ershiba xiaohui  margin_top">开票时间：{{dataAll.opentime_text}}</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid:"",
				pid:"",
				data_type:1,//1酒店，2商品
				dataAll:{},
				pageShow:false,
				dataAll:{}
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.pid = options.pid
			this.data_type = options.data_type
			// this.getDetail()
			this.getfpDetail()
		},
		methods: {
			saveimg(filePath){
				uni.downloadFile({ //下载文件资源到本地,返回文件的本地临时路径
				 	url: filePath, //网络图片路径
					success:(res) => {
						var imageUrl = res.tempFilePath; //临时文件路径
						uni.saveImageToPhotosAlbum({ //保存图片到系统相册
							filePath: imgUrl,
							success: (res) => {
								httpRequest.toast("保存成功")
							},
							fail: (err) => {
								console.log('图片保存失败');
							}
						})
					}
				})
			},
			getDetail(){
				let url = "/api/order/goodsOrderFpSure"
				if(this.data_type==1){
					url = "/api/hotelordercl/hotelOrderFpSure"
				}
				httpRequest.request(url, 'GET', {
					id: this.pid
				}, false, false, true).then(res => {
					this.dataAll = res.data
				})
			},
			getfpDetail(){
				let url = "/api/user/userFpDetail"
				httpRequest.request(url, 'GET', {
					id: this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.sptp {
		width: 124rpx;
		height: 124rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}
.fpbjt{
	width: 100%;
	height: 406rpx;
	border-radius: 14rpx 14rpx 14rpx 14rpx;
}
</style>
